package com.aaa.book_mall.entity;

import java.io.Serializable;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * @author Lei Chu
 * @Date 2020/10/17 16:09
 */

public class Staff implements Serializable {

  private Integer id;
  private Integer staffId;
  private String staffName;
  private String password;
  private String phone;
  private String idCard;
  private String address;
  private String createdTime;
  private String resignedTime;
  private Integer status;
  private Integer roleId;
  private String rname;
  private Integer deptid;
  private String dname;
  private String url;
  private Integer age;
  private Integer page;
  private Integer limit;


  public void setPassword() {
    this.password = "123123";
  }

  public void setAge() {
    //获取当前时间的年月日---->Calendar:日历类
    Calendar cal = Calendar.getInstance();
    int yearNow = cal.get(Calendar.YEAR);
    int monthNow = cal.get(Calendar.MONTH)+1;
    int dayNow = cal.get(Calendar.DATE);

    //根据此员工的身份证号获取年月日
    int year = Integer.parseInt(this.idCard.substring(6, 10));
    int month = Integer.parseInt(this.idCard.substring(10,12));
    int day = Integer.parseInt(this.idCard.substring(12,14));

    if ((month < monthNow) || (month == monthNow && day<= dayNow) ){
      this.age = yearNow - year;
    }else {
      this.age = yearNow - year-1;
    }
  }

  public void setCreatedTime() {
    SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd");
    Date date = new Date(System.currentTimeMillis());
    this.createdTime = formatter.format(date);
  }

  public Integer getId() {
    return id;
  }

  public void setId(Integer id) {
    this.id = id;
  }

  public Integer getStaffId() {
    return staffId;
  }

  public void setStaffId(Integer staffId) {
    this.staffId = staffId;
  }

  public String getStaffName() {
    return staffName;
  }

  public void setStaffName(String staffName) {
    this.staffName = staffName;
  }

  public String getPassword() {
    return password;
  }

  /*public void setPassword(String password) {
    this.password = password;
  }*/

  public String getPhone() {
    return phone;
  }

  public void setPhone(String phone) {
    this.phone = phone;
  }

  public String getIdCard() {
    return idCard;
  }

  public void setIdCard(String idCard) {
    this.idCard = idCard;
  }

  public String getAddress() {
    return address;
  }

  public void setAddress(String address) {
    this.address = address;
  }

  public String getCreatedTime() {
    return createdTime;
  }

  public void setCreatedTime(String createdTime) {
    this.createdTime = createdTime;
  }

  public String getResignedTime() {
    return resignedTime;
  }

  public void setResignedTime(String resignedTime) {
    this.resignedTime = resignedTime;
  }

  public Integer getStatus() {
    return status;
  }

  public void setStatus(Integer status) {
    this.status = status;
  }

  public Integer getRoleId() {
    return roleId;
  }

  public void setRoleId(Integer roleId) {
    this.roleId = roleId;
  }

  public String getRname() {
    return rname;
  }

  public void setRname(String rname) {
    this.rname = rname;
  }

  public Integer getDeptid() {
    return deptid;
  }

  public void setDeptid(Integer deptid) {
    this.deptid = deptid;
  }

  public String getDname() {
    return dname;
  }

  public void setDname(String dname) {
    this.dname = dname;
  }

  public String getUrl() {
    return url;
  }

  public void setUrl(String url) {
    this.url = url;
  }

  public Integer getAge() {
    return age;
  }

  public void setAge(Integer age) {
    this.age = age;
  }

  public Integer getPage() {
    return page;
  }

  public void setPage(Integer page) {
    this.page = page;
  }

  public Integer getLimit() {
    return limit;
  }

  public void setLimit(Integer limit) {
    this.limit = limit;
  }

  @Override
  public String toString() {
    return "Staff{" +
            "id=" + id +
            ", staffId=" + staffId +
            ", staffName='" + staffName + '\'' +
            ", password='" + password + '\'' +
            ", phone='" + phone + '\'' +
            ", idCard='" + idCard + '\'' +
            ", address='" + address + '\'' +
            ", createdTime='" + createdTime + '\'' +
            ", resignedTime='" + resignedTime + '\'' +
            ", status=" + status +
            ", roleId=" + roleId +
            ", rname='" + rname + '\'' +
            ", deptid=" + deptid +
            ", dname='" + dname + '\'' +
            ", url='" + url + '\'' +
            ", age=" + age +
            ", page=" + page +
            ", limit=" + limit +
            '}';
  }
}
